function out = warping3(in, X, Y, Z, X1, Y1, Z1, method)

if ~exist(method, 'var')
    method = 'linear';
end

out = interp3(Y, X, Z, in, Y1, X1, Z1, method);
out(isnan(out)) = 0;